import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login.vue'
import Layout from '@/views/layout.vue'
import Home from '@/views/home.vue'
import Qa from '@/views/qa.vue'
import Video from '@/views/video.vue'
import My from '@/views/my.vue'
import Search from '@/views/search.vue'
import Article from '@/views/article.vue'
import UserProfile from '@/views/user-profile.vue'
Vue.use(VueRouter)

/**
 * @type {import('vue-router').RouteConfig[]} // 路由配置提示
 */
const routes = [
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/',
    // name: 'layout',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'home',
        component: Home
      },
      {
        path: 'qa',
        name: 'qa',
        component: Qa
      },
      {
        path: 'video',
        name: 'video',
        component: Video
      },
      {
        path: 'my',
        name: 'my',
        component: My
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: Search
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: Article,
    props: true
  },
  {
    path: '/user/profile',
    name: 'user-profile',
    component: UserProfile
  }
]

const router = new VueRouter({
  routes
})

export default router
